home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
VISUALBA
/
BOZOL2.ZIP
/
DB.BAS
< prev
next >
Wrap
BASIC Source File
|
1994-02-08
|
35KB
|
1,022 lines
' DBASE III COMPATIBLE DATA FILE INTERFACE for PowerBASIC 3.0+
'
' dBASE interface, screen field editing, and indexing routines by Erik Olson
' with Joe Vest's BT() BTree subroutine and a modified field input routine
' by David Zarnitsky. Special thanks to Bob Zale for making me do this.
' Routine list (detailed descriptions follow)
' dBASE .DBF file access
' dBUse(STRING,INTEGER)
' dBGetRecord(DWORD,INTEGER)
' dBGetCField$(STRING,INTEGER)
' dBGetNField!(STRING,INTEGER)
' dBPutRecord(DWORD,INTEGER)
' dBPutCField(STRING, STRING, INTEGER)
' dBPutNField(STRING, SINGLE, INTEGER)
' utilities
' dBGetASCII$()
' dBGetARRAY(STRING ARRAY,INTEGER)
'
' index support
' dBSetIndexTo(IX$,Fld$,e%)
' dBCreateIndex(IX$, Fld$, e%)
' dBSearchIndex(Findme$,e%)
' dBSkip(NS%, e%)
' dBGotoTop(e%)
' dBGotoBottom(e%)
' screen editing
' dBCreateFormat ()
' dBSetFormatTo (FormatFileName$,Ecode%)
' dBView ()
' dBEditFields (Ecode%)
' dBEditRecord (RecNum???,E%)
' dBAppendRecord (E%)
%FALSE = 0
%TRUE = NOT %FALSE
%INSERTSCAN = 3 ' Change these two to change shape of cursor
%OVERWRITESCAN = 6 ' The higher the number, the smaller the cursor
' SUB or FUNCTION declaration Example use and description
'==================================== ===========================
DECLARE SUB dBUse(STRING,INTEGER) ' dBUse "TEST.DBF", ErrorCode%
' ErrorCode returns
' 1 - file not found
' 2 - Zero byte file
' 3 - File has no fields
' 4 - not a dBASE file
DECLARE SUB dBGetRecord(DWORD,INTEGER) ' dBGetRecord R???, ErrorCode%
' ErrorCode returns
' 1 - database not open
' 2 - record exceeds size
' 3 - record => zero
DECLARE FUNCTION dBGetCField$(STRING,INTEGER)
' ErrorCode 1 if no such field
' A$=dBGetCField$("PHONE",e%)
' returns the string value of a
' character field
DECLARE FUNCTION dBGetNField!(STRING,INTEGER)
' A! = dBGetNField!("TOTAL",e%)
' ErrorCode 1 if no such field
' Returns a single precision number
' of a numeric field with proper
' decimal places
DECLARE SUB dBPutRecord(DWORD,INTEGER) ' dBPutRecord(R???,ErrorCode%)
' Returns error 1 if no dbase open
' Returns error 2 if record too hi
' Puts the current record in memory
' into the database at the record
' specified. If record number is
' 1 higher than NumberOfRecords???
' or if it is 0 then the record will
' be appended to the database
DECLARE SUB dBPutCField(STRING, STRING, INTEGER)
' dBPutCField "NAME", "Erik", Ecode%
' returns error if no such field
' places a string value into a
' character field in memory
DECLARE SUB dBPutNField(STRING, SINGLE, INTEGER)
' dBPutNField "AGE", 27, Ecode%
' returns error if no such field
' places a numeric value into a
' character field in memory. Numeric
' argument is formatted according to
' the design of the field
DECLARE SUB dBCreateFormat () ' runs a mini program to create a
' data entry screen format. The
' current format or a default format
' (of up to 44 fields) is created.
' you then move the fields around
' on the screen with the arrow
' keys and press ENTER when finished.
DECLARE SUB dBSetFormatTo(FormatFileName$,Ecode%)
' dBSetFormatTo "SCREEN1.FRM", E%
' Loads screen edit format file and
' returns. If not successful error
' code returns 1 for file not found.
' If filename is nul string then
' the current format is cleared.
' Ecode% returns 1 if the format
' file is not found.
DECLARE SUB dBView () ' Uses the current screen format to
' simply display the current record.
' it does not pause.
DECLARE SUB dBEditFields(Ecode%) ' uses the current screen format to
' display and then allow editing of
' the current record in typical
' dBASE fashion. CTRL-END or F10
' terminates and updates the record.
' ESCAPE terminates and does not
' update the record.
DECLARE SUB dBEditRecord(RecNum???,E%) ' Gets a record and allows fullscreen
' editing using current screen format
' or default screen format if no
' current format is set. e% returns
' 1 if the specified record does not
' exist.
DECLARE SUB dBAppendRecord(E%) ' Creates a blank record and allows
' full screen editing. If the record
' is not aborted it will be appended
' to the database. Uses the current
' screen format or default format if
' no format is set. e% returns 1 if
' the record cannot be appended to
' the database for whatever reason.
DECLARE FUNCTION dBGetASCII$() ' A$ = dBGetASCII$
' returns a comma delimited ASCII
' record of the entire dBASE record
' currently in memory
DECLARE SUB dBGetARRAY(STRING ARRAY,INTEGER)
' dBGetARRAY DB$,e%
' fills the specified array with
' consecutive fields from the entire
' dBASE record currently in memory.
' ErrorCode 1 is array is too small
DECLARE SUB dBSetIndexTo(IX$,Fld$,e%) ' Set index to file in IX$. You must
' specify the field which is being
' indexed in order to properly update
' the index during append or edit
' operations. The index must have
' already been created using
' dBCreateIndex. E% returns 1 if the
' database is not open, 2 if the
' specified field is not in the
' database, 3 if the index file
' does not exist
DECLARE SUB dBCreateIndex(IX$, Fld$, e%)' Creates an index file specified in
' IX$. You must specify the field
' to index in FLD$. As the file is
' being indexed, record numbers are
' printed to the screen at the
' current cursor location. e%
' returns 1 if the database is not
' open, 2 if the field does not
' exist, 3 if the index can't be
' created on disk, 4 if there is
' an error reading the database,
' 5 if the user aborts with ESC,